import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.liu.Excel.ServeTrainItemExcel;
import com.liu.dto.ServeTrainItemDto;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class ExcelMake {
    @Test
    public void writer(){
        List<ServeTrainItemExcel> list = new ArrayList<>();
        for (int i = 1; i < 100; i++) {
            list.add(new ServeTrainItemExcel(i,i,i,new Date(),new Date(),i,
                    new Random().nextInt(2),new Random().nextInt(2)
                    ,new Random().nextInt(2),new Date(),new Date()));
        }
        System.out.println(list);

        EasyExcel.write("trainItemDto.xlsx", ServeTrainItemExcel.class).sheet().doWrite(list);
    }
    @Test
    public void read(){
        List<ServeTrainItemExcel> list= EasyExcel.read("trainItemDto.xlsx", ServeTrainItemDto.class, new ReadListener() {
            @Override
            public void invoke(Object o, AnalysisContext analysisContext) {
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {

            }
        }).sheet().doReadSync();
        System.out.println(list);
    }

}
